package com.aivin.waterfallflow.tool;

import android.app.Activity;
import android.content.Context;
import android.util.DisplayMetrics;
import android.view.WindowManager;

public class MyDeviceInforHelper {
	public static int getScreenWidth(Context context) {
		WindowManager wm = (WindowManager) context   .getSystemService(Context.WINDOW_SERVICE);
		return wm.getDefaultDisplay().getWidth();
	}


	public static int dp2px(Context context, float dpValue) {
		final float scale = context.getResources().getDisplayMetrics().density;
		return (int) (dpValue * scale + 0.5f);
	}

	private static DisplayMetrics myDisplayMetrics ;
	private static DisplayMetrics myGetDisplayMetrics( ) {
		if(myDisplayMetrics==null){
			myDisplayMetrics = new DisplayMetrics();
		}
		return myDisplayMetrics;
	}



	public static int getRealHeight(Activity mActivity) {
		mActivity.getWindowManager().getDefaultDisplay().getRealMetrics(myGetDisplayMetrics());
		return  myGetDisplayMetrics().heightPixels;
	}


	public static int getWidth(Activity mActivity) {
		mActivity.getWindowManager().getDefaultDisplay().getMetrics(myGetDisplayMetrics());
		return  myGetDisplayMetrics().widthPixels;
	}


}
